/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package neuronalenetzeelearning.view.help;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author maria
 */
public class HelpUtil {

    public static String readFileToString(String filename) {
        FileInputStream fis = null;
        try {
            System.out.println("Reading file: " + filename);
            File file = new File(filename);
            System.out.println("File==null:" + (file == null));
            InputStreamReader inputStreamReader = null;
            fis = new FileInputStream(file);
            inputStreamReader = new InputStreamReader(fis, "utf-8");
            char[] xmlBuffer = new char[(int) file.length()];
            int charsRead = inputStreamReader.read(xmlBuffer);
            String string = new String(xmlBuffer, 0, charsRead);
            System.out.println("Read string: \n" + string);
            //            xml = xml.replaceAll("\n", "&#10;");
            //            xml = xml.replaceAll("\r", "&#13;");
            return string;
        } catch (UnsupportedEncodingException ex) {
            Logger.getLogger(HelpUtil.class.getName()).log(Level.SEVERE, null, ex);
        } catch (FileNotFoundException ex) {
            Logger.getLogger(HelpUtil.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IOException ex) {
            Logger.getLogger(HelpUtil.class.getName()).log(Level.SEVERE, null, ex);
        } finally {
            try {
                fis.close();
            } catch (IOException ex) {
                Logger.getLogger(HelpUtil.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
        return null;
    }

    public static void main(String[] args) {
        HelpUtil.readFileToString("src/neuronalenetzeelearning/view/help/resources/propertyGraphPanelHelp");
    }
}
